import axios from '../../http/http'
import * as url from '../../http/api'
const state = {
    //--------------------员工表
    yglist: [],
    ygjob: [],
    ygstore: [],
    /* yglist: [
        {
            id: "1",
            name: "1",
            sex: 1,
            storeName: "后勤",
            jobName: "保洁员",
            jobId: '1',
            storeId: '2',
            baseSalary: "3500",
            tel: "123456",
            password: '123',
            number: '123',
            idCard: '123123123123123123'
        },
        {
            id: "2",
            name: "2",
            sex: 2,
            storeName: "后勤",
            jobName: "保洁员",
            baseSalary: "3500",
            tel: "123456",
            password: '123',
            number: '123',
            idCard: '123123123123123123',
            jobId: '1',
            storeId: '2',
        },
        {
            id: "3",
            name: "3",
            sex: "1",
            storeName: "后勤",
            jobName: "保洁员",
            baseSalary: "3500",
            tel: "123456",
            password: '123',
            number: '123',
            idCard: '123123123123123123',
            jobId: '1',
            storeId: '2',
        },
        {
            id: "4",
            name: "4",
            sex: "1",
            storeName: "后勤",
            jobName: "保洁员",
            baseSalary: "3500",
            tel: "123456",
            password: '123',
            number: '123',
            idCard: '123123123123123123',
            jobId: '1',
            storeId: '2',
        },
        {
            id: "5",
            name: "5",
            sex: "1",
            storeName: "后勤",
            jobName: "保洁员",
            baseSalary: "3500",
            tel: "123456",
            password: '123',
            number: '123',
            idCard: '123123123123123123',
            jobId: '1',
            storeId: '2',
        },
        {
            id: "6",
            name: "6",
            sex: "1",
            storeName: "后勤",
            jobName: "保洁员",
            baseSalary: "3500",
            tel: "123456",
            password: '123',
            number: '123',
            idCard: '123123123123123123',
            jobId: '1',
            storeId: '2',
        },
        {
            id: "7",
            name: "7",
            sex: "1",
            storeName: "后勤",
            jobName: "保洁员",
            baseSalary: "3500",
            tel: "123456",
            password: '123',
            number: '123',
            idCard: '123123123123123123',
            jobId: '1',
            storeId: '2',
        },
        {
            id: "8",
            name: "8",
            sex: "1",
            storeName: "后勤",
            jobName: "保洁员",
            baseSalary: "3500",
            tel: "123456",
            password: '123',
            number: '123',
            idCard: '123123123123123123',
            jobId: '1',
            storeId: '2',
        },
        {
            id: "9",
            name: "9",
            sex: "1",
            storeName: "后勤",
            jobName: "保洁员",
            baseSalary: "3500",
            tel: "123456",
            password: '123',
            number: '123',
            idCard: '123123123123123123',
            jobId: '1',
            storeId: '2',
        },
        {
            id: "10",
            name: "10",
            sex: "1",
            storeName: "后勤",
            jobName: "保洁员",
            baseSalary: "3500",
            tel: "123456",
            password: '123',
            number: '123',
            idCard: '123123123123123123',
            jobId: '1',
            storeId: '2',
        },
        {
            id: "11",
            name: "11",
            sex: "1",
            storeId: "后勤",
            jobName: "保洁员",
            baseSalary: "3500",
            tel: "123456",
            password: '123',
            number: '123',
            idCard: '123123123123123123',
            jobId: '1',
            storeId: '2',
        },
        {
            id: "12",
            name: "12",
            sex: "1",
            storeName: "后勤",
            jobName: "保洁员",
            baseSalary: "3500",
            tel: "123456",
            password: '123',
            number: '123',
            idCard: '123123123123123123',
            jobId: '1',
            storeId: '2',
        },
    ], */
    // --------------------部门表
    /* bmlist: [
        { id: 1, storeName: '部门1' },
        { id: 2, storeName: '部门2' },
        { id: 3, storeName: '部门3' },
        { id: 4, storeName: '部门4' },
    ], */
    // 职位表及职位人数
    zwlist: [],
    zwNum: [],
    /*  zwNum: [
         { jobName: '职位1', 数量: '12' }
     ], */
    /* zwlist: [
        { id: 1, jobName: '职位1', remark: '备注信息', updateBy: '更新人', updateTime: '更新时间', createBy: '创建人', createTime: '创建时间' },
        { id: 2, jobName: '职位2', remark: '备注信息', updateBy: '更新人', updateTime: '更新时间', createBy: '创建人', createTime: '创建时间' },
        { id: 3, jobName: '职位3', remark: '备注信息', updateBy: '更新人', updateTime: '更新时间', createBy: '创建人', createTime: '创建时间' },
        { id: 4, jobName: '职位4', remark: '备注信息', updateBy: '更新人', updateTime: '更新时间', createBy: '创建人', createTime: '创建时间' },
    ], */
    // --------------------权限表
    qxlist: []
    /*  qxlist: [
         { id: 1, name: '服务员', remark: '备注信息', updateBy: '更新人', updateTime: '更新时间', createBy: '创建人', createTime: '创建时间' },
         { id: 2, name: '管理员', remark: '备注信息', updateBy: '更新人', updateTime: '更新时间', createBy: '创建人', createTime: '创建时间' },
         { id: 3, name: '超级管理员', remark: '备注信息', updateBy: '更新人', updateTime: '更新时间', createBy: '创建人', createTime: '创建时间' },
         { id: 4, name: '会计', remark: '备注信息', updateBy: '更新人', updateTime: '更新时间', createBy: '创建人', createTime: '创建时间' },
     ] */
}
const actions = {
    ygData({ commit }) { //获得员工信息 包含对应员工职位map  部门map
        return axios({
            url: url.SELYG,
            method: 'post'
        }).then(res => {
            // console.log(res)
            commit('addYgList', res.data)
        })
    },
    ygAtherData({ commit }) { //职位表，对应职位的人数
        return axios({
            url: url.SELJOBANDSTORE,
            method: 'post'
        }).then(res => {
            // console.log(res)
            commit('addJobAndStore', res.data)
        })
    },
    qxData({ commit }) { //权限表
        return axios({
            url: url.SELQX,
            method: 'post',
        }).then(res => {
            // console.log(res.data.RolePermi)
            commit('addQxList', res.data)
        })
    },
    upZwData({ commit }, obj) { //更新查询职位的数据
        commit('upZw', obj)
    },
    upYgData({ commit }, obj) {
        commit('upYg', obj)
    }
}
// ---------------------------------------------------------------------------
const mutations = {
    addYgList(state, obj) { //员工数据放到state（包含员工对应部门，职位）
        state.yglist = obj.list
        state.ygjob = []
        state.ygstore = []
        for (let key in obj.map2) { //部门
            state.ygstore[key] = obj.map2[key]
        }
        for (let key in obj.map1) { //职位
            // console.log(obj.map1[key])
            state.ygjob.push(obj.map1[key])
        }

    },
    addJobAndStore(state, obj) { //职位和职位下的人数
        state.zwNum = [] //职位人数
        state.zwlist = obj.list1 //职位表
        // console.log(obj.list1)
        for (let key in obj.map) {
            state.zwNum.push(obj.map[key])
        }
        // console.log(state.zwlist)
    },
    addQxList(state, obj) {
        state.qxlist = []
        state.qxlist = obj.RolePermi
    },
    // -----------------------------------------------------------------
    upZw(state, obj) { //查询的职位数据替换原有的数据
        state.zwlist = obj
    },
    upYg(state, obj) { //查询的员工数据替换原有的数据
        state.yglist = obj
    }
}

const getters = {

}

export default {
    state,
    actions,
    mutations,
    getters
}











